package org.jumiz.javafx.client;

import javafx.application.Application;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.jumiz.javafx.business.ApplicationContext;
import org.jumiz.javafx.client.pages.commonents.JumizScene;
import org.jumiz.javafx.client.pages.login.LoginPage;
import org.jumiz.javafx.client.util.FileUtil;
import org.jumiz.javafx.client.util.SwitchScene;

public class ClientApplication extends Application {

    public static void start(String[] args) {
        try {
            LoggerContext context = (LoggerContext) LogManager.getContext(false);
            context.setConfigLocation(FileUtil.loadCss("log4j.xml").toURI());
            context.reconfigure();

            ApplicationContext.init();
        } catch (Exception e) {
            e.printStackTrace();
        }

        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
//        LoginPage loginPage = new LoginPage();
//        LayoutPane layoutPane = new LayoutPane();
//        primaryStage.setTitle("hello world");
//        primaryStage.setResizable(false);
//        SwitchScene.registerStage(primaryStage);
//        SwitchScene.switchScene(loginPage);

        WebView webView = new WebView();
        WebEngine engine = webView.getEngine();
        engine.load("http://www.baidu.com");


        JumizScene jumizScene = new JumizScene(webView);
        primaryStage.setScene(jumizScene);
        primaryStage.show();
    }

}
